#include <stdio.h>

void stream_attribute(FILE *fp)
{
	if(fp->_flags & _IO_UNBUFFERED)
		printf("This IO is unbuffered\n");
	else if(fp->_flags & _IO_LINE_BUF)
		printf("This IO is line buffered\n");
	else
		printf("This IO is full buffered\n");

	printf("This IO buffer size is %d\n", fp->_IO_buf_end - fp->_IO_buf_base);
	
}

void main(void)
{
	FILE *fp;
	getchar();
	
	stream_attribute(stdin);
	printf("______________________\n\n");
	stream_attribute(stdout);
	printf("______________________\n\n");
	stream_attribute(stderr);
	printf("______________________\n\n");

	if(!(fp = fopen("test", "w+")))
		perror("failed to open");

	printf("before write : \n");
	stream_attribute(fp);

	fputc('a', fp);

	printf("after write : \n");
	stream_attribute(fp);
	
}
